package cn.scut.post.dao;

import cn.scut.post.pojo.Post;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface PostInfoDao extends BaseMapper<Post> {
    @Update("insert into post values(#{post.postid},#{post.openid}," +
            "#{post.tag},#{post.title},#{post.content},#{post.commentsCount},#{post.date})")
    void uploadPost(@Param("post") Post post);

    @Select("select * from post where openid=#{openid}")
    Post selectByOpenid(String openid);

    @Select("select * from post where postid=#{postid}")
    Post selectByPostid(String postid);

    @Update("delete from post where postid=#{postid}")
    int deleteByPostId(String postid);
}
